#ifndef _SPI_PANEL_INIT_H
#define _SPI_PANEL_INIT_H

#include "sys.h"
#include "delay.h"
	
#define SPI_PANEL_SCK							GPIO_PIN_12//CLK	??
#define SPI_PANEL_SCK_Periph_GPIO				GPIOD
			
#define SPI_PANEL_MISO							GPIO_PIN_3//MISO ????
#define SPI_PANEL_MISO_Periph_GPIO				GPIOE
			
#define SPI_PANEL_MOSI							GPIO_PIN_13//MOSI ????
#define SPI_PANEL_MOSIPeriph_GPIO				GPIOD
			
#define ARM_PANEL_OE1							GPIO_PIN_11		//DCX
#define ARM_PANEL_OE_Periph_GPIO				GPIOD

#define SPI_PANEL_CS1							GPIO_PIN_4      //CS
#define SPI_PANEL_CS_Periph_GPIO				GPIOE		

//#define M25P64_CS0							GPIO_PIN_2 //  M25P64??
//#define M25P64_CS_Periph_GPIO					GPIOF

#define CS1_PANEL 	0X01
#define CS2_PANEL		0x02
#define CS1_2_PANEL	0x03

void SPI_PANEL_IO_init(void);
void SPI_PANEL_CS_Select(u8 channel,u8 Enable);
void SPI_PANEL_Write_u8_Cmd(u8 SPI_Mode,u8 channel,u8 cmd);
void SPI_PANEL_Write_u8_Cmd_NoCS(u8 SPI_Mode,u8 cmd);
void SPI_PANEL_Write_u8_Data(u8 SPI_Mode,u8 channel,u8 data);
void SPI_PANEL_Write_u8_Data_NoCS(u8 SPI_Mode,u8 data);
u8   SPI3_PANEL_Read_u8_Data(u8 channel);
u8   SPI3_PANEL_Read_u8_Data_NoCS(void);
u16  SPI3_PANEL_Read_u16_Data(u8 channel);
u8 SPI4_PANEL_Read_u8_Data(u8 SPI_Mode,u8 channel ,u8 cmd);
u8 SPI4_PANEL_Read_u8_Data_page(u8 SPI_Mode,u8 channel ,u8 page ,u8 cmd);
void SPI_PANEL_Write_code(u8 SPI_Mode,u8 channel ,u8 cmd,u8 data);
void SPI_PANEL_Write_u8_Array(u8 SPI_Mode,u8 channel ,u8* para);
//void SPI_PANEL_Set_Window(u8 SPI_Mode,u8 channel ,u16 x0,u16 x1,u16 y0,u16 y1);
void SPI_PANEL_WriteRAM_buffer_part(u8 SPI_Mode,u8 channel ,u8* buffer ,u16 length,u8  multiple ,u8 Flag,u8 DUAL_SPI_MODE,u8 RGB_fromat);
void SPI3_PANEL_WriteRAM(u8 SPI_Mode,u8 channel ,u16 H_OLED,u16 V_OLED,u8 R,u8 G, u8 B, u8 flag,u8 RGB_fromat);
void SPI_PANEL_Write_u8_Array_code(u8 SPI_Mode,u8 channel ,u8* para);
void GenW_PANEL_SPI_Write_code(u8 SPI_Mode,u8 channel ,u8 para[]);
u8 GenR_PANEL_SPI4_Read_u8_Data(u8 SPI_Mode,u8 channel,u8 reg,u8 para[],u8 back_num);
u8 GenR_SPI4_Read_u8_Data_3line(u8 SPI_Mode,u8 channel,u8 reg,u8 *para,u8 back_num); //用于通用4线SPI，读写一根线
u8 GenR_SPI4_Read_u8_Data_3line_Page0(u8 SPI_Mode,u8 channel,u8 reg,u8 *para,u8 back_num); //用于通用4线SPI，读写一根线 ,page00
u8 SPI4_PANEL_Read_u8_Data_cuihuashan_page(u8 SPI_Mode,u8 channel ,u8 page, u8 cmd);


void SPI_PANEL_Write_u8_Array_37350(u8 SPI_Mode,u8 channel ,u8* para,u8 len);
u8 SPI4_PANEL_Read_u8_Data_array_37350(u8 SPI_Mode,u8 channel ,u8* para,u8 len);
u8 SPI4_PANEL_Read_u8_Data_array_GenWR(u8 SPI_Mode,u8 channel ,u8 reg,u8* para,u8 len);
//u8 SPI4_PANEL_Read_u8_Data_array(u8 SPI_Mode,u8 channel ,u8* para);
//u8 SPI4_PANEL_Read_u8_Data_array_SDA(u8 SPI_Mode,u8 channel ,u8* para);

#endif


